#include <QtSql>
#include <QMessageBox>

#include "gudaywellwindow.h"
#include "daysform.h"

GudaywellWindow::GudaywellWindow(QWidget *parent)
	:QMainWindow(parent)
{	
	setupUi(this);
	createRelationalTables();
	
	tabWidget = new QTabWidget;
	DaysForm *daysForm=new DaysForm;
	tabWidget->addTab(daysForm,"Days");
	
	setCentralWidget(tabWidget);
	connect( actionSetting,SIGNAL( triggered() ),this,SLOT(showSetting()));
}

void GudaywellWindow::showSetting()
{
	setting.show();
	
}

void GudaywellWindow::createRelationalTables()
{
     QSqlQuery query;
     query.exec("insert into gadwl values(1, 1, 0, 1, 1, 1)");
     query.exec("insert into gadwl values(2, 2, 1, 2, 2, 2)");
     query.exec("insert into gadwl values(3, 3, 2, 3, 3, 3)");
}

void GudaywellWindow::on_actionNew_triggered()
{
	DaysForm *daysForm=new DaysForm;
	int index = tabWidget->addTab(daysForm,"untitled");
	tabWidget->setCurrentIndex(index);
}

void GudaywellWindow::on_actionClose_triggered()
{
	tabWidget->removeTab( tabWidget->currentIndex() );
}

void GudaywellWindow::on_actionAbout_Gudaywell_triggered()
{
	QString aboutText;
	aboutText = "Gudaywell is a simple application for managing "
				"school schedules."
				"\nCoded by Mohamed Assar <mohsr@gmail.com> (c) 2006"
				"\nVersion 0.0.1"
				"\n\nIcons by Tango-Project.org";
	QMessageBox::about(this,QString("About Gudaywell"),aboutText);
}

void GudaywellWindow::on_actionAbout_Qt_triggered()
{
	QMessageBox::aboutQt(this);
}
